<?php
/**
 * 企业人才库
 * @author chenhao 2010-01-14
 */
include( "inc/header.php" );
login_check( );

//删除
if($_GET['Action']=='del'){
	if (isset($_POST['checkRecord'])) {
		$id = implode(',',$_POST['checkRecord']);
	}else {
		$id = $_GET['id'];
	}
	if (!empty($id)) {
		$db->query("DELETE FROM tun2_hr_data WHERE id IN ($id)");
		addlog("删除企业人才库中人才信息", $_SESSION['user_name']);
	}else {
		admin_showerrs('操作错误，请至少选择一条人才信息',null,0);
	}
}
?>
<table width="98%" border="1" align="center" cellpadding="5" cellspacing="0" class="table">
  <tr>
    <td>如果你人才库操作方面遇到什么问题或困难，请与<a href="http://www.22cn.cn" target="_blank">呜雷科技</a>联系</td>
  </tr>
</table>
<br />
<table width="98%" border="1" align="center" cellpadding="5" cellspacing="0" class="table">
<form id="searchForm" name="SearchForm" method="post" action="Admin_hr.php">
  <tr>
    <td width="13%" align="right"><strong>搜索：</strong></td>
    <td width="51%"><label>
      <input type="text" name="keywords" value="<?=$_POST['keywords']?>" />
      <input type="submit" name="Submit" value="搜 索" />
    </label></td>
    <td width="36%"><strong>查看方式：</strong><a href="Admin_hr.php?order=school_record">学历</a>&nbsp;&nbsp; <a href="Admin_hr.php?order=workage">工作年限</a></td>
  </tr>
  </form>
</table>
<br />
<table width="98%" border="1" align="center" cellpadding="5" cellspacing="0" class="table">
  <tr>
    <td align="center" width="20">&nbsp;</td>
    <td align="center" width="40"><strong>ID</strong></td>
    <td align="center"><strong>姓名</strong></td>
    <td align="center"><strong>姓别</strong></td>
    <td align="center"><strong>申请职位</strong></td>
    <td align="center"><strong>工作年限</strong></td>
    <td align="center"><strong>学历</strong></td>
    <td align="center"><strong>通讯地址</strong></td>
    <td align="center"><strong>操作</strong></td>
  </tr>
  <form id="checkBoxForm" name="checkBoxForm" method="post" action="Admin_hr.php?Action=del">
  <?php
  @$intPerpage = 20; //默认每页显示20条
  if ( $_GET['PB_page'] ){
  	$offset = ( $_GET['PB_page'] - 1 ) * $intPerpage;
  }else{
  	$offset = 0;
  }
  
  $sql="SELECT * From tun2_hr_data WHERE 1=1 ";
  $execc = "SELECT id From tun2_hr_data WHERE 1=1 ";
  if (isset($_POST['keywords'])) {
  	$sql .= "AND name LIKE '%".$_POST['keywords']."%' OR place LIKE '%".$_POST['keywords']."%' OR address LIKE '%".$_POST['keywords']."%'";
  	$execc .= "AND name LIKE '%".$_POST['keywords']."%' OR place LIKE '%".$_POST['keywords']."%' OR address LIKE '%".$_POST['keywords']."%'";
  }
  if (isset($_GET['order'])) {
  	$sql .= "ORDER BY '$_GET[order]' DESC LIMIT ".$offset.",{$intPerpage}";
  }else {
  	 $sql .= "ORDER BY id DESC LIMIT ".$offset.",{$intPerpage}";
  }
  $query = mysql_query($execc);
  $intNum = mysql_num_rows($query);
  
  $db->query($sql);
  while($db->next_record()) {
  ?>
  <tr>
    <td align="center"><input type="checkbox" name="checkRecord[]" value="<?=$db->Record['id']?>" /></td>
    <td align="center"><?=$db->Record['id']?></td>
    <td align="center"><?=$db->Record['name']?></td>
    <td align="center"><?=($db->Record['sex']==0)?'男':'女';?></td>
    <td><?=getOffice($db->Record['id']);?></td>
    <td align="center"><?=getWorkage($db->Record['workage'])?></td>
    <td align="center"><?=getSchoolRecord($db->Record['school_record'])?></td>
    <td align="center"><?=$db->Record['address']?></td>
    <td align="center" width="120"><a href="Admin_hr_look.php?id=<?=$db->Record['id']?>">详情</a>&nbsp;&nbsp; <a href="Admin_hr.php?Action=del&id=<?=$db->Record['id']?>" onclick="delcfm();">删除</a></td>
  </tr>
  <?php
  }
  if($db->next_record()){
  ?>
  <tr>
  	<td colspan="9" align="center">记录不存在</td>
  </tr>
  <?php }?>
  <tr>
  	<td>&nbsp;</td>
  	<td colspan="8"><input type="submit" name="submit" value="批量删除选中项"></td>
  </tr>
  <tr>
  	<td colspan="9" height="40" align="center">
  	<?php
    //分页类
    require_once( "../inc/class.page.php" );
    class mypage extends page
    {

    	public function show( )
    	{
    		$_showpage = "<div class=\"pagenavi\" id=\"lopage\">";
    		$_showpage .= $this->first_page( )." ";
    		$_showpage .= $this->nowbar( "", "curr" );
    		$_showpage .= "<span class=\"break\">...</span>";
    		$_showpage .= $this->last_page( );
    		$_showpage .= "   (总计<span class=\"num\">".$this->totalpage."</span>页 <span class=\"num\">".$this->total."</span>条记录)</div>";
    		$_showpage .= "</div>";
    		return $_showpage;
    	}

    }
    $page = new mypage( array(
    "total" => $intNum,
    "perpage" => $intPerpage
    ) );
    echo $page->show( );
    ?>
  	</td>
  </tr>
  </form>
</table>
